﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//
using ddcCajamarca.BusinessEntities.AgendaCultural;
using System.Data.Entity.ModelConfiguration;
using System.ComponentModel.DataAnnotations.Schema;
namespace ddcCajamarca.Repository.Mapping
{
    public class EventoMap : EntityTypeConfiguration<Evento>
    {
        public EventoMap()
        {
            this.HasKey(e => e.Id);
            this.Property(e => e.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.Property(e => e.NombreEvento).HasColumnType("varchar").IsRequired().HasMaxLength(255);
            this.Property(e => e.Descripcion).HasColumnType("varchar").IsRequired().HasMaxLength(800);
            this.Property(e => e.Sintesis).HasColumnType("varchar").IsRequired().HasMaxLength(255);
            this.Property(e => e.Modalidad).HasColumnType("varchar").IsRequired().HasMaxLength(17);
            this.Property(e => e.Precio).HasColumnType("decimal").HasPrecision(9, 2).IsOptional();
            //    this.Property(e => e.Imagen).HasColumnType("image").IsOptional();
            this.Property(e => e.Imagen).IsOptional();
            //this.Property(e => e.HoraInicio).IsRequired();
            //this.Property(e => e.HoraFin).IsRequired();
            this.Property(e => e.HoraInicio).HasColumnType("datetime2").IsRequired();
            this.Property(e => e.HoraFin).HasColumnType("datetime2").IsRequired();
            this.Property(e => e.FechaInicio).HasColumnType("date").IsRequired();
            this.Property(e => e.FechaFin).HasColumnType("date").IsRequired();
            this.Property(e => e.Total).HasColumnType("decimal").HasPrecision(9, 2).IsOptional();

            this.ToTable("Evento");
            this.Property(e => e.Id).HasColumnName("IdEvento");
            this.Property(e => e.NombreEvento).HasColumnName("NomEvento");
            this.Property(e => e.Descripcion).HasColumnName("DescripcionEvento");
            this.Property(e => e.Sintesis).HasColumnName("SintesisEvento");
            this.Property(e => e.Modalidad).HasColumnName("ModalidadEvento");
            this.Property(e => e.Precio).HasColumnName("PrecioEvento");
            this.Property(e => e.Imagen).HasColumnName("ImagenEvento");
            this.Property(e => e.HoraInicio).HasColumnName("HoraInicioEvento");
            this.Property(e => e.HoraFin).HasColumnName("HoraFinEvento");
            this.Property(e => e.FechaInicio).HasColumnName("FechaInicioEvento");
            this.Property(e => e.FechaFin).HasColumnName("FechaFinEvento");

            this.HasRequired(e => e.Ambiente).WithMany(e => e.Eventoes)
                .HasForeignKey(e => e.AmbienteId).WillCascadeOnDelete(false);

            this.HasRequired(e => e.TipoEvento).WithMany(e => e.Eventoes)
                .HasForeignKey(e => e.TipoEventoId).WillCascadeOnDelete(false);

        }
    }
}
